<?php
	require_once('config.inc.php');
	
		
	class Database
	{
		private $connection;
		
		public function __construct()
		{
			global $config;
			$connectionString = 'host='.$config['db_host'].' user='.$config['db_user'].' password='.$config['db_pass'].' dbname='.$config['db_name'];
			$this->connection = pg_pconnect($connectionString) or die('PostgreSQL connection failed: '.$connectionString);
		}
		
		public function query($queryString)
		{
			$result = array();
			$query = pg_query($this->connection,$queryString);
			if(!$query) throw new Exception(pg_last_error($this->connection));
			while($row = pg_fetch_array($query,null,PGSQL_ASSOC))
			{
				$result[] = $row;
			}
			return $result;
		}
	}
?>